package cn.iocoder.yudao.module.nginxui.dal.mysql.httpconfig;

import java.util.*;

import cn.iocoder.yudao.framework.common.pojo.PageResult;
import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX;
import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX;
import cn.iocoder.yudao.module.nginxui.dal.dataobject.httpconfig.HttpConfigDO;
import org.apache.ibatis.annotations.Mapper;
import cn.iocoder.yudao.module.nginxui.controller.admin.httpconfig.vo.*;
import org.apache.ibatis.annotations.Param;

/**
 * Nginx HTTP块主配置 Mapper
 *
 * @author HuangJunZhong
 */
@Mapper
public interface HttpConfigMapper extends BaseMapperX<HttpConfigDO> {

    default PageResult<HttpConfigDO> selectPage(HttpConfigPageReqVO reqVO) {
        return selectPage(reqVO, new LambdaQueryWrapperX<HttpConfigDO>()
                .eqIfPresent(HttpConfigDO::getConfigId, reqVO.getConfigId())
                .eqIfPresent(HttpConfigDO::getSendfile, reqVO.getSendfile())
                .eqIfPresent(HttpConfigDO::getKeepaliveTimeout, reqVO.getKeepaliveTimeout())
                .eqIfPresent(HttpConfigDO::getClientMaxBodySize, reqVO.getClientMaxBodySize())
                .eqIfPresent(HttpConfigDO::getLogFormat, reqVO.getLogFormat())
                .eqIfPresent(HttpConfigDO::getExtraHttpConfig, reqVO.getExtraHttpConfig())
                .eqIfPresent(HttpConfigDO::getStatus, reqVO.getStatus())
                .betweenIfPresent(HttpConfigDO::getCreateTime, reqVO.getCreateTime())
                .orderByDesc(HttpConfigDO::getId));
    }


    HttpConfigDO selectByConfigIdAndStatus(
            @Param("configId") Long configId,
            @Param("status") Integer status
    );
}